<?php
// 定义生辰石数据
$birthstones = [
    1 => ['name' => '石榴石', 'meaning' => '象征忠实、友爱和贞操'],
    2 => ['name' => '紫水晶', 'meaning' => '代表诚实、平和'],
    3 => ['name' => '海蓝宝石', 'meaning' => '寓意着沉着、勇敢和聪明'],
    4 => ['name' => '钻石', 'meaning' => '象征着纯净、永恒和坚贞不渝'],
    5 => ['name' => '祖母绿', 'meaning' => '代表幸运、幸福，使人有信心'],
    6 => ['name' => '珍珠', 'meaning' => '寓意着健康、安宁和富贵'],
    7 => ['name' => '红宝石', 'meaning' => '象征热情、爱情和活力'],
    8 => ['name' => '橄榄石', 'meaning' => '代表着和平、幸福、安详等美好意愿'],
    9 => ['name' => '蓝宝石', 'meaning' => '寓意忠诚、坚贞、慈爱和诚实'],
    10 => ['name' => '欧泊', 'meaning' => '象征希望和纯洁'],
    11 => ['name' => '黄玉', 'meaning' => '代表友谊和爱情，有助于佩戴者保持平静和理智'],
    12 => ['name' => '绿松石', 'meaning' => '寓意着成功和必胜']
];

// 初始化结果变量
$result = '';

// 处理表单提交
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $birthdate = $_POST['birthdate'];
    $month = (int)date('n', strtotime($birthdate));

    if (array_key_exists($month, $birthstones)) {
        $stone = $birthstones[$month];
        $result = "您出生月份对应的生辰石是 {$stone['name']}，它的寓意是 {$stone['meaning']}。";
    } else {
        $result = "抱歉，未找到对应月份的生辰石信息。";
    }
}
?>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查生辰石游戏</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <h1>查生辰石游戏</h1>
    <form method="post">
        <label for="birthdate">请输入您的生日：</label>
        <input type="date" id="birthdate" name="birthdate" required>
        <input type="submit" value="查询">
    </form>
    <?php if ($result): ?>
        <div id="result">
            <p><?php echo $result; ?></p>
        </div>
    <?php endif; ?>
</body>

</html>